import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import p003 from './p003';

export default async function a004(fd: IFeidaoAiBrowserComponent, address: string) {
	// 修改页面样式
	const add = fd.data.node.querySelector<HTMLElement>('[data-id="add"]');
	set_node_cls(add, 'display-n', false);
	if (address === undefined) {
		return;
	} else {
		// 获取维护说明
		const remark = fd.data.node.querySelector<HTMLTextAreaElement>('[data-id="remark"]').value;
		// 获取
		const timeout_reminder_time = fd.data.node.querySelector<HTMLInputElement>('[data-id="timeout_reminder_time"]').value;
		// tslint:disable-next-line:radix
		let timeout_alert = Number.parseInt(fd.data.node.querySelector<HTMLSelectElement>('[data-id="timeout_alert"]').value);
		// tslint:disable-next-line:use-isnan
		if (timeout_alert === NaN) {
			timeout_alert = 1;
		}
		const maintenance_time = fd.data.node.querySelector<HTMLInputElement>('[data-id="maintenance_time"]').value;
		const dt = {
			address,
			maintenance_time,
			timeout_alert,
			remark,
			timeout_reminder_time
		};
		render(fd, dt, p003, 'p003', 'inner');
	}
}
